Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Fix #140, #167, address a comment in #144 and rework the bearer middleware tests #168

Merged
merged 2 commits into from
Apr 13, 2015
Merged

Conversation

kevinchalet
Copy link
Contributor

The PR is a bit noisy but I had to rework large parts of various tests, that were not really conclusive.

(GitHub accidentally closed my previous PR when I rebased it (#142) so I had to re-submit it)

@ghost
Copy link

ghost commented Mar 3, 2015

Hi @PinpointTownes, I'm your friendly neighborhood Microsoft Open Technologies, Inc. Pull Request Bot (You can call me MSOTBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft Open Technologies, Inc. and real humans are currently evaluating your PR.

TTYL, MSOTBOT;

@ghost ghost added the cla-not-required label Mar 3, 2015
@kevinchalet kevinchalet changed the title Fix #140 and rework the different OAuth2 Bearer middleware tests Fix #140, #167, address a comment in #144 and rework the bearer middleware tests Mar 3, 2015
@kevinchalet
Copy link
Contributor Author

I also included fixes for #144 (comment), #167 and the casing issue of OpenidConnectAuthenticationHandler.cs

@kevinchalet
Copy link
Contributor Author

/cc @brentschmaltz @Praburaj @Tratcher

@@ -566,7 +565,7 @@ public override Task<bool> InvokeAsync()
{
if (ticket.Principal != null)
{
Request.HttpContext.Response.SignIn(ticket.AuthenticationScheme, ticket.Principal, ticket.Properties);
Request.HttpContext.Response.SignIn(Options.SignInScheme, ticket.Principal, ticket.Properties);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is already in.

/CC @HaoK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this one line is in, so yeah a rebase probably would make this diff go away, this PR has more than that fix though, I am not familiar enough with this code to determine whether these other changes are appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Praburaj rebased, thanks 👯

@Praburaj
Copy link
Contributor

Praburaj commented Mar 5, 2015

Changes look good to me. @tushargupta51 - could you also review?

@@ -46,9 +45,14 @@ public class OpenIdConnectAuthenticationMiddleware : AuthenticationMiddleware<Op
{
_logger = loggerFactory.CreateLogger<OpenIdConnectAuthenticationMiddleware>();

if (string.IsNullOrEmpty(Options.SignInScheme))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is SignInScheme used for?

@tushargupta51
Copy link
Contributor

The changes to the bearer middleware tests looks good.

@@ -4,8 +4,6 @@
using System;
using Microsoft.AspNet.Authentication.Cookies.Infrastructure;
using Microsoft.AspNet.Authentication.DataHandler;
using Microsoft.AspNet.Authentication.Cookies.Infrastructure;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally unrelated changes, but these 2 lines were causing compilation warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a few minutes ago by @HaoK: e2bb762

@kevinchalet
Copy link
Contributor Author

Rebased.

@kevinchalet
Copy link
Contributor Author

Squashed to incorporate feedback in the appropriate commits.

@kevinchalet
Copy link
Contributor Author

Conflict fixed.

@HaoK @tushargupta51 @brentschmaltz any chance you could have a final look and merge it? 😄

@HaoK
Copy link
Member

HaoK commented Mar 19, 2015

I'll try to get to this after my hosting changes are done...

@kevinchalet
Copy link
Contributor Author

@HaoK thanks. Don't hesitate to ping me if there are conflicts that need to be fixed.

@kevinchalet
Copy link
Contributor Author

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

Yeah looks good, go ahead and normalize the doc comments to be consistent, I'll merge this in soon

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

I'm not suggesting you make this change in this PR, but what do you think about maybe ExternalAuthenticationOptions -> SignInSchemeOptions is that better or worse? I'm not sure what's a good property name if we did that, Scheme or AuthenticationScheme perhaps?

@kevinchalet
Copy link
Contributor Author

Personally, I think I'd simply remove ExternalAuthenticationOptions and rely exclusively on OAuthAuthenticationOptions/OpenIdConnectAuthenticationOptions/TwitterAuthenticationOptions to set up SignInScheme: I'm convinced it would make this "delegated persistence" stuff more evident and easier to understand for end developers.

We could also set a default value (Cookies to match the default scheme for the cookies middleware? But IIRC, that's not the default scheme used by aspnet/Identity) for these properties, so people wouldn't have to set an explicit value for basic cookies + social provider scenarios..

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

Yeah so the idea is we want to easily configure all of the auth middlewares via one central services.Configure(options => options.SignInScheme = "Cookie"). Otherwise any app that's using Google/Facebook/Twitter/MAuth would need to do this for every auth middleware mechanically (and the error story if you misconfigure this is pretty poor)

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

The intent is basically to be the centralized default SignInScheme, which might not be a bad name: SignInOptions.DefaultSignInScheme, as all auth middlewares would use this as the default scheme for their SignInScheme

@kevinchalet
Copy link
Contributor Author

Indeed, removing ExternalAuthenticationOptions would make global SignInScheme more painful to set up as you'd have to configure it for each authentication middleware 😄

Another approach: the OIDC/OAuth2/Twitter options could inherit from ExternalAuthenticationOptions and stop exposing a custom SignInScheme. The default scheme could be configured via services.Configure<ExternalAuthenticationOptions>(options => options.SignInScheme = "Cookie") as you suggested, and it could be replaced by services.Configure<OpenIdConnectAuthenticationOptions>(options => options.SignInScheme = "Other").

That said, I'm not sure it would work as-is with the current aspnet/Options bit. In this case, would OpenIdConnectAuthenticationOptions automagically be created with the settings applied to ExternalAuthenticationOptions it inherits from?

SignInOptions.DefaultSignInScheme sounds like a good name, though it's not obvious it would only be supported by OIDC/OAuth2/Twitter providers.

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

Yeah configuration options doesn't really look at inheritance, you are configuring a singleton per TOptions, so you'd be configuring only the base options, which if noone is asking for, will be ignored. So that doesn't work unfortunately.

Yeah perhaps we still need something that sounds like External/Delegating/NonAutomatic something that conveys that this is for the non automatic auth middlewares to use.

[GoodNameForNonAutomatic]AuthenticationOptions.DefaultSignInScheme i think is the correct name, just need to find a replacement for External

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

Perhaps we could just use a grab all SharedAuthenticationOptions.DefaultSignInScheme?

@Tratcher what do you think about renaming ExternalAuthenticationOptions to be something more general?

@Tratcher
Copy link
Member

Tratcher commented Apr 9, 2015

@HaoK Sounds fine. It doesn't have any other fields.

@brentschmaltz
Copy link
Contributor

@HaoK Help me understand what SignInScheme is used for and if it is completely implemented?

@HaoK
Copy link
Member

HaoK commented Apr 9, 2015

@brentschmaltz refer to @PinpointTownes update to the doc comments, its fairly clear, nothing has changed in its meaning or intent since Katana, we just renamed it from SignInAsAuthenticationType

https://github.com/PinpointTownes/Security/commit/39a970c8f25b685e462f165aa768c0c929cbbad3

@kevinchalet
Copy link
Contributor Author

@brentschmaltz if you think it's not clear enough, creating a wiki page with various code samples and copying the URL in the documentation might be a good option.

@HaoK
Copy link
Member

HaoK commented Apr 13, 2015

@PinpointTownes Do you want to squash your commits down to one or two? If I do it, the changes will look like mine instead of yours.

@kevinchalet
Copy link
Contributor Author

@HaoK done. I hope the commits will be descriptive enough 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants